﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using YArchitech.Revit;

namespace HangerSupport
{
	public class HSFilter : ISelectionFilter
	{
		public static bool IsHSElement(Element elem, string strFamilyName = "")
		{
			bool flag = !(elem is FamilyInstance);
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				FamilyInstance familyInstance = elem as FamilyInstance;
				bool flag2 = familyInstance == null;
				if (flag2)
				{
					result = false;
				}
				else
				{
					FamilySymbol symbol = familyInstance.Symbol;
					bool flag3 = symbol == null;
					if (flag3)
					{
						result = false;
					}
					else
					{
						Parameter parameter = symbol.GetParameter("HY_HS_TYPE");
						bool flag4 = parameter != null;
						if (flag4)
						{
							bool flag5 = strFamilyName.CompareTo("") != 0;
							if (flag5)
							{
								string name = symbol.Family.Name;
								result = (name == strFamilyName);
							}
							else
							{
								result = true;
							}
						}
						else
						{
							result = false;
						}
					}
				}
			}
			return result;
		}

		public bool AllowElement(Element elem)
		{
			return HSFilter.IsHSElement(elem, "");
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}
}
